// pages/infoYz/components/business/index.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    list: [
      {
        title: '发货单位',
        text1: '上传特殊资质证件完成开通服务',
        icon: 'fhdw',
        statusClass: 'status-pending',
        key: 'name1',
        formShow: false,
        formList: [
          {
            key: 'name1',
            value: '',
            backCall: function () {
              console.log('4444')
            },
            msgText: '拍摄上传特殊资质证件'
          },
          {
            key: 'name2',
            value: '',
            backCall: function () {
              console.log('4444')
            },
            msgText: '拍摄上传特殊资质证件2'
          }
        ]
      },
      {
        title: '物业公司',
        text1: '上传特殊资质证件完成开通服务',
        icon: 'wygs',
        iconWidth: '60%',
        iconHight: '60%',
        statusClass: 'status-ywc',
        key: 'name1',
        formShow: false,
        formList: [
          {
            key: 'name1',
            value: '',
            backCall: function () {
              console.log('4444')
            }
          }
        ]
      },
      {
        title: '居委村委',
        text1: '上传特殊资质证件完成开通服务',
        icon: 'cwh',
        iconWidth: '60%',
        iconHight: '60%',
        statusClass: 'status-pending',
        key: 'name1',
        formShow: false,
        formList: [
          {
            key: 'name1',
            value: '',
            backCall: function () {
              console.log('4444')
            }
          }
        ]
      },
      {
        title: '运输公司',
        text1: '上传道路运输许可证件完成开通服务',
        icon: 'ysgs',
        statusClass: 'status-pending',
        iconWidth: '60%',
        iconHight: '60%',
        key: 'name1',
        formShow: false,
        formList: [
          {
            key: 'name1',
            value: '',
            backCall: function () {
              console.log('4444')
            }
          }
        ]
      },
      {
        title: '收纳场',
        text1: '上传建筑垃圾处理证开通服务',
        icon: 'snc',
        iconWidth: '80%',
        iconHight: '80%',
        statusClass: 'status-pending',
        key: 'name1',
        formShow: false,
        formList: [
          {
            key: 'name1',
            value: '',
            backCall: function () {
              console.log('4444')
            }
          }
        ]
      },
      {
        title: '车辆机械设备租赁供应商',
        text1: '上传特殊资质证件完成开通服务',
        icon: 'setting-car',
        iconWidth: '60%',
        iconHight: '60%',
        statusClass: 'status-pending',
        key: 'name1',
        formShow: false,
        formList: [
          {
            key: 'name1',
            value: '',
            backCall: function () {
              console.log('4444')
            }
          }
        ]
      }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handelClickitem (e) {
      const {index} = e.currentTarget.dataset
      const mb = this.data.list
      mb[index].formShow = !mb[index].formShow 
      this.setData({list: mb})
    },
    chooseFrontImage(e) {
      const {index, i} = e.currentTarget.dataset
      wx.chooseImage({
        count: 1,
        success: (res) => {
          const mb = this.data.list
          mb[index].formList[i].value = res.tempFilePaths[0]
          this.setData({list: mb})
          // this.setData({ frontImage: res.tempFilePaths[0] });
          // 这里可添加OCR识别逻辑，自动填充车牌号码和注册日期
        }
      });
    },
  }
})